include("fs");

var logNo;

if (typeof(logNo) == "undefined") {
		logNo = 0;
	}

var date = new Date();
	
var session = new (require("session").Session)(request, response); 
var counter = session.get("LoggerCounter");	
if (counter == null) counter=0;
	
var file = new File("logs/" + 
		date.getMonth() + " " + date.getDate() + " - " + 
		date.getHours() + " " + date.getMinutes() + " " + date.getSeconds() + " - " + counter + ".log");
	logNo = logNo + 1;
	file.open('w');
	
session.set("LoggerCounter", counter +1);
session.save();

exports.logger = {};

exports.logger.log = function(str) {
		file.write(str + "\n");
	};
	
exports.logger.close = function() {
		file.flush();
		file.close();
	};
	